import {
	defineStore
} from 'pinia';

export const useMainStore = defineStore({
	id: 'main', // store 的唯一标识符
	state: () => ({
		currentUser: {
			
		}, //当前登录用户信息
		orderId: "",
		orderCarImage: [],
		serviceItem: [], //选择的服务
		selectedManager: {}, //选择的主管
		selectedWorker: [], //选择的师傅
	}),
	actions: {
		set_currentUser(value) { //存储当前用户信息(包括token)
			this.currentUser = value
		},
		set_orderId(value) { //存储产生的订单id
			this.orderId = value
		},
		set_orderCarImage(value) { //存储车子图片的网络地址
			this.orderCarImage.push(value);
		},
		clear_oderInfo() { //清空选择的服务和选择的图片
			this.orderId = "";
			this.serviceItem = [];
			this.orderCarImage = [];
		},
		set_serviceItem(value) { //存储选择的服务和产品对象压入数组
			this.serviceItem.unshift(value);
		},
		delete_serviceItem(value) { //删除选择的服务和产品
			this.serviceItem.splice(value, 1);
		},
		set_selectedManager(value) { //存储选择的主管
			this.selectedManager = value
		},
		clear_selectedManager(value) { //清除选择的主管
			this.selectedManager = {}
		},
		set_selectedWorker(value) { //存储选择的师傅
			this.selectedWorker.push(value)
		},
		delete_selectedWorker(value) { //删除一个师傅
			this.selectedWorker.splice(value, 1)
		},
		clear_selectedWorker() { //清除选择的师傅
			this.selectedWorker = []
		}
	}
});